package cn.stylefeng.guns.modular.biz.controller;

import cn.stylefeng.guns.modular.biz.entity.LabMainInfo;
import cn.stylefeng.guns.modular.biz.pojo.request.LabMainInfoRequest;
import cn.stylefeng.guns.modular.biz.service.LabMainInfoService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * MES煤的质检数据控制器
 *
 * @author 张朋飞
 * @since 2024/09/29 21:24
 */
@RestController
@ApiResource(name = "MES煤的质检数据")
public class LabMainInfoController {

    @Resource
    private LabMainInfoService labMainInfoService;

    /**
     * 添加MES煤的质检数据
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @PostResource(name = "添加MES煤的质检数据", path = "/labMainInfo/add")
    public ResponseData<LabMainInfo> add(@RequestBody @Validated(LabMainInfoRequest.add.class) LabMainInfoRequest labMainInfoRequest) {
        labMainInfoService.add(labMainInfoRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 删除MES煤的质检数据
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @PostResource(name = "删除MES煤的质检数据", path = "/labMainInfo/delete")
    public ResponseData<?> delete(@RequestBody @Validated(LabMainInfoRequest.delete.class) LabMainInfoRequest labMainInfoRequest) {
        labMainInfoService.del(labMainInfoRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 批量删除MES煤的质检数据
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @PostResource(name = "批量删除MES煤的质检数据", path = "/labMainInfo/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) LabMainInfoRequest labMainInfoRequest) {
        labMainInfoService.batchDelete(labMainInfoRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑MES煤的质检数据
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @PostResource(name = "编辑MES煤的质检数据", path = "/labMainInfo/edit")
    public ResponseData<?> edit(@RequestBody @Validated(LabMainInfoRequest.edit.class) LabMainInfoRequest labMainInfoRequest) {
        labMainInfoService.edit(labMainInfoRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 查看MES煤的质检数据详情
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @GetResource(name = "查看MES煤的质检数据详情", path = "/labMainInfo/detail")
    public ResponseData<LabMainInfo> detail(@Validated(LabMainInfoRequest.detail.class) LabMainInfoRequest labMainInfoRequest) {
        return new SuccessResponseData<>(labMainInfoService.detail(labMainInfoRequest));
    }

    /**
     * 获取MES煤的质检数据列表
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @GetResource(name = "获取MES煤的质检数据列表", path = "/labMainInfo/list")
    public ResponseData<List<LabMainInfo>> list(LabMainInfoRequest labMainInfoRequest) {
        return new SuccessResponseData<>(labMainInfoService.findList(labMainInfoRequest));
    }

    /**
     * 获取MES煤的质检数据列表（带分页）
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @GetResource(name = "获取MES煤的质检数据列表（带分页）", path = "/labMainInfo/page")
    public ResponseData<PageResult<LabMainInfo>> page(LabMainInfoRequest labMainInfoRequest) {
        return new SuccessResponseData<>(labMainInfoService.findPage(labMainInfoRequest));
    }

}
